<extend name="./Application/Admin/View/Public/base.html" />
<block name="eosi-css">
    <link href="__PUBLIC__/assets/css/daterangepicker.css" rel="stylesheet">
    <link href="__PUBLIC__/assets/css/iconfont.css" rel="stylesheet">
    <link href="__PUBLIC__/assets/css/rili.css" rel="stylesheet">
    <link href="__PUBLIC__/assets/css/fileUpload.css?v=11" rel="stylesheet">
</block>
<block name="eosi-js"> 
    <script src="__PUBLIC__/assets/js/date-time/bootstrap-datepicker.min.js"></script>
    <script src="__PUBLIC__/assets/js/jqGrid/laydate.dev.js"></script>
    <script src="__PUBLIC__/assets/js/jqGrid/jquery.jqGrid.min.js"></script>
    <script type="text/javascript">
        var $path_base = "/";//this will be used in gritter alerts containing images
    </script>

</block>
<block name="page-content">
    <div class="row">
        <div class="col-xs-12">
            <div class="row-fluid">
                <div class="span12">
                    <div class="widget-box">
                        <div class="widget-header header-color-blue">
                            <h5 class="lighter">
                                编辑类别管理<span class="red">(带*为必填项)</span>
                            </h5>
                        </div>
                        <div class="widget-body">
                            <div class="widget-main no-padding">
                                <form class="form-horizontal"  name="saveForm" id="saveForm"  method="post"  action="{:U('updateRule')}" encType="multipart/form-data">
                                    <input type="hidden" name="id" id="id" value="{$data.id}">
                                    <table class="table table-striped table-bordered table-hover">
                                        <tbody>

                                            <tr>
                                                <td class="no-padding-right" width="15%">
                                                    <label class="control-label"><small>类别名称<span class="red">*</span></small></label>
                                                </td>
                                                <td>
                                                    <!-- <select  id="test"  name="name"> 
                                                        <volist name="_listopt" id="opt"> 
                                                            <option <if condition="$data.id == $opt['id']"  
                                                            > selected </if> value ="{$opt.name}"  >{$opt.name}</option>
                                                        </volist>
                                                    </select> -->
                                                    <input type="text" id="name" name="name" value="{$data.name}" class="col-xs-10 col-sm-4" />

                                                </td>
                                            </tr>
                                            
                                            <tr>
                                                <td class="no-padding-right" width="15%">
                                                    <label class="control-label"><small>默认显示图片<span class="red">*</span></small></label>
                                                </td>
                                                <td>
                                                    <img src='{$data.img}' id="img" name="img" >
                                                    <input type="file" name="p_img" id="p_img">
                                                    <span class="middle control-label red">&nbsp;&nbsp;图片建议尺寸：59(w)x80(h)像素</span>
                                                    <input type="hidden" id="p_new_pic" name="p_new_pic" value="{$data.img}">
                                                    <iframe style="display: none;" id="upload_img" name="upload_img"></iframe>
                                                </td>
                                            </tr>


                                            <tr>
                                                <td class="no-padding-right" width="15%">
                                                    <label class="control-label"><small>状态<span class="red">*</span></small></label>
                                                </td>
                                                <td>
                                                <input type="radio" name="status" value="1" <if condition="$data.status == 1 "> checked </if>>启用
                                                    <input type="radio" name="status" value="0" <if condition="$data.status == 0 "> checked </if>>禁用
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="no-padding-right" width="15%">
                                                    <label class="control-label"><small>显示顺序<span class="red">*</span></small></label>
                                                </td>
                                                <td>
                                                    <input type="text" id="show_order" name="show_order" value="{$data.show_order}" class="col-xs-10 col-sm-4" />
                                                    <span class="middle control-label red">&nbsp;&nbsp; 请填入数字，值越大越靠前显示</span>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="no-padding-right" width="15%">
                                                    <label class="control-label"><small>选中显示图片<span class="red">*</span></small></label>
                                                </td>
                                                <td>
                                                    <img src='{$data.choose_img}' id="choose_img" name="choose_img" >
                                                    <input type="file" name="pp_img" id="pp_img">
                                                    <span class="middle control-label red">&nbsp;&nbsp;图片建议尺寸：59(w)x80(h)像素</span>
                                                    <input type="hidden" id="pp_new_pic" name="pp_new_pic" value="{$data.choose_img}">
                                                    <iframe style="display: none;" id="uupload_img" name="uupload_img"></iframe>
                                                </td>
                                            </tr>  
                                        </tbody>
                                    </table>

                                    <table class="table table-striped table-bordered table-hover" id="answer">
                                        <tbody>
                                            <tr>
                                                <td class="no-padding-right" width="15%">

                                                </td>
                                                <td>
                                                    <button class="btn btn-success" type="button" style="cursor: pointer;" onclick="checkSubmit();">
                                                        <i class="icon-ok bigger-110"></i>
                                                        提交
                                                    </button>
                                                    <button class="btn btn-warning" type="button" style="cursor: pointer;" onclick="returnButton();">
                                                        <i class="icon-undo bigger-110"></i>
                                                        返回
                                                    </button>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div><!-- /.row -->
    <!-- <script src="__PUBLIC__/assets/js/jqGrid/i18n/fileUpload.js"></script> -->
    <script type="text/javascript">
        jQuery(function ($) {
            //提交Form
            checkSubmit = function () {
                var id = $("#id").val();
                if (id == '') {
                    art.dialog.alert("待更新数据不存在，请刷新页面重试");
                    return false;
                }
                var p_new_pic = $("#p_new_pic").val();
                if (p_new_pic == '') {
                    art.dialog.tips("请上传一张商品首图");
                    return false;
                }
                
                $("#saveForm").attr('action', "{:U('updateRule')}");
                $("#saveForm").attr('target', '_self');
                $("form[name=saveForm]").submit();
            }
            returnButton = function () {
                location.href = "/Admin/BhType/index";
            }
        });
        $("#p_img").change(function() {
                    // alert(1);
                    $("#saveForm").attr('action', "{:U('uploadImg')}");
                    $("#saveForm").attr('target', 'upload_img');
                    $("#saveForm").submit();
                });
        $("#pp_img").change(function() {
                    // alert(1);
                    $("#saveForm").attr('action', "{:U('uuploadImg')}");
                    $("#saveForm").attr('target', 'uupload_img');
                    $("#saveForm").submit();
                });
    </script>

</block>